import static org.junit.Assert.*;

import org.junit.Test;

/*Values for all "assertEqual" tests were taken from the dive table*/
public class DiveComputerTest {
	

        DiveComputer dive = new DiveComputer();
       
        @Test
        public void testGUI() {
                assertNotNull(dive);
        }
        
        //We tested the extremes of this method but it is restricted by the UI and we felt it didn't need to be tested further than this.
        @Test
        public void testFindDepthInput() {
                assertEquals(DiveComputer.findDepthIndex(55), 2);
                assertEquals(DiveComputer.findDepthIndex(0), 0);
                assertEquals(DiveComputer.findDepthIndex(130), 9);
        }
        
        
        //We felt testing "findTimeIndex" was not as important as testing "testSafetyStop" since "testSafetyStop" is an extension to and ignores bad inputs to "findTimeIndex".
        @Test
        public void testFindTimeIndex() {
                assertEquals(DiveComputer.findTimeIndex(dive.diveTime, 2, 23), 4);
                
        }
        //Pressure group only prints the pressure group and is not critical for safety.  We did not feel like we needed to extensively test this method.
        @Test
        public void testPressureGroup() {
                assertEquals(DiveComputer.pressureGroup(4), 'E');
        }
       
        //We focused most of our tests here since this is where all inputs get validated.
        @Test
        public void testSafetyStop() {
                assertEquals(DiveComputer.safetyStop(0, 150), true);
                assertEquals(DiveComputer.safetyStop(0, 151), false);
                assertEquals(DiveComputer.safetyStop(1, 100), true);
                assertEquals(DiveComputer.safetyStop(1, 101), false);
                assertEquals(DiveComputer.safetyStop(2, 80), true);
                assertEquals(DiveComputer.safetyStop(2, 81), false);
                assertEquals(DiveComputer.safetyStop(3, 70), true);
                assertEquals(DiveComputer.safetyStop(3, 71), false);
                assertEquals(DiveComputer.safetyStop(4, 60), true);
                assertEquals(DiveComputer.safetyStop(4, 500), false);
                assertEquals(DiveComputer.safetyStop(5, 50), true);
                assertEquals(DiveComputer.safetyStop(5, 500), false);
                assertEquals(DiveComputer.safetyStop(6, 40), true);
                assertEquals(DiveComputer.safetyStop(6, 50), false);
                assertEquals(DiveComputer.safetyStop(7, 30), true);
                assertEquals(DiveComputer.safetyStop(7, 31), false);
                assertEquals(DiveComputer.safetyStop(8, 30), true);
                assertEquals(DiveComputer.safetyStop(8, 31), false);
                assertEquals(DiveComputer.safetyStop(9, 25), true);
                assertEquals(DiveComputer.safetyStop(9, 26), false);
        }
        
        //We did not extensively test this because the UI restricts inputs to this method
        @Test
        public void testFindSurfaceIndex() {
        		assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 0, .50), 0);
        		assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 11, .10), 11);
                assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 6, 0.34), 6);
                assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 6, 0.42), 5);
                assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 6, 2.0), 3);
                assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 11, 11), 0);
                assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 11, 1100000), 0);
                assertEquals(DiveComputer.findSurfaceIndex(dive.surfaceTime, 5, 0.10), 5);
        }
        
}

